<html>
<head><meta charset="utf-8"><title>impl Trait everywhere · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html">impl Trait everywhere</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196956577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196956577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196956577">(May 08 2020 at 22:14)</a>:</h4>
<p>Hey folks. So I've gotten pretty interested in trying to push impl Trait through to stability. I think it's crucial for async code, for one thing, but it's also pretty squarely in the Rust roadmap mandate of "finishing up unfinishing things".</p>
<p>I've spend a number of hours today preparing notes. They're not yet in a form that can be consumed by the public, but I will try to arrange them better. I want to propose that we use an upcoming design meeting for this topic -- perhaps May 20th? </p>
<p>Things I am trying to ultimately pull together:</p>
<ul>
<li>Discrepancies between the implementation and what the RFCs said, and the reasons for them (and how we might resolve them).</li>
<li>Lingering unspecified details to be resolved.</li>
<li>Stabilization "schedule" -- what should be stabilized and when?</li>
</ul>
<p>I think the meeting would probably focus on the first two, plus perhaps some amount of "review".</p>
<p>cc <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> <span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="121053">@varkor</span> <span class="user-mention" data-user-id="256759">@boats</span> , folks who I know have had a lot of interest in <code>impl Trait</code> in the past.</p>



<a name="196956799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196956799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196956799">(May 08 2020 at 22:17)</a>:</h4>
<p>If you're glutton for punishment, my notes are in <a href="https://github.com/nikomatsakis/lang-team/blob/impl-trait-everywhere/src/design_notes/impl_trait_everywhere.md" title="https://github.com/nikomatsakis/lang-team/blob/impl-trait-everywhere/src/design_notes/impl_trait_everywhere.md">this file</a> -- the section on "philosophy" however didn't quite work out as beautifully as I hoped and has some unfinished ramblings for me to reconcile. =) Though I still think the core idea is reasonable.</p>



<a name="196957159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957159">(May 08 2020 at 22:21)</a>:</h4>
<p>(I would probably enjoy some "pre-design meeting" discussion too.)</p>



<a name="196957299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957299">(May 08 2020 at 22:23)</a>:</h4>
<p>I am interested in discussing this, but I'll need to refresh my memory on the whole topic; I'll try to do so over the weekend.</p>



<a name="196957312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957312">(May 08 2020 at 22:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Thank you for the <em>detailed</em> example showing everywhere it might make sense.</p>



<a name="196957341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957341">(May 08 2020 at 22:24)</a>:</h4>
<p>it's missing a case or two still, notably structs</p>



<a name="196957459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957459">(May 08 2020 at 22:25)</a>:</h4>
<p>Do "where clause position" and "associated type binding position" remain identical when used in trait methods?</p>



<a name="196957470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957470">(May 08 2020 at 22:25)</a>:</h4>
<p>Or does there need to be a "trait method where clause position" and similar?</p>



<a name="196957511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957511">(May 08 2020 at 22:25)</a>:</h4>
<p>Also, the example right up at the top that you called "named" might benefit from an "also known as 'type alias'".</p>



<a name="196957606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957606">(May 08 2020 at 22:26)</a>:</h4>
<p>Another few cases, which may be identical to existing cases:</p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="n">closure_arg</span>: <span class="nc">impl</span><span class="w"> </span><span class="n">Trait</span><span class="o">|</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Trait</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="196957609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957609">(May 08 2020 at 22:26)</a>:</h4>
<p>I believe so, but i'm going to add to the cod for now to remind me to think more about it</p>



<a name="196957645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957645">(May 08 2020 at 22:27)</a>:</h4>
<p>notably I think it's not entirely clear the precise circumstances in which <code>impl Trait</code> should be permitted in where causes (I think it largely should not, except for in associated type binding positions)</p>



<a name="196957737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957737">(May 08 2020 at 22:28)</a>:</h4>
<p>Interesting. Why is the one you labeled "where clause position" not something you'd want to support?</p>



<a name="196957743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957743">(May 08 2020 at 22:28)</a>:</h4>
<p>It seems generally useful.</p>



<a name="196957770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957770">(May 08 2020 at 22:29)</a>:</h4>
<p>because the obvious interpretation to me creates an unconstrained type parameter</p>



<a name="196957776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957776">(May 08 2020 at 22:29)</a>:</h4>
<p>and you have no way to specify its value</p>



<a name="196957800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957800">(May 08 2020 at 22:29)</a>:</h4>
<p>that said, there are other plausible interpretations</p>



<a name="196957801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957801">(May 08 2020 at 22:29)</a>:</h4>
<p>What do you mean by "unconstrained type parameter"?</p>



<a name="196957863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957863">(May 08 2020 at 22:30)</a>:</h4>
<p>consider </p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="k">where</span><span class="w"> </span><span class="kt">u32</span>: <span class="nb">PartialOrd</span><span class="o">&lt;</span><span class="k">impl</span><span class="w"> </span><span class="n">Debug</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>



<a name="196957879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957879">(May 08 2020 at 22:30)</a>:</h4>
<p>I believe that probably "wants to" desugar to</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="k">where</span><span class="w"> </span><span class="kt">u32</span>: <span class="nb">PartialOrd</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>



<a name="196957900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957900">(May 08 2020 at 22:30)</a>:</h4>
<p>but what is this <code>T</code>?</p>



<a name="196957915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957915">(May 08 2020 at 22:31)</a>:</h4>
<p>That doesn't seem like the right desugar.</p>



<a name="196957925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957925">(May 08 2020 at 22:31)</a>:</h4>
<p>in the latter case, the user can specify, but in the former case, they cannot, and there are many types that <code>u32</code> can be ordered with</p>



<a name="196957934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957934">(May 08 2020 at 22:31)</a>:</h4>
<p>that is one possible interpretation, yes, another plausible desugar is</p>



<a name="196957952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957952">(May 08 2020 at 22:31)</a>:</h4>
<p>It should desugar to:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="k">where</span><span class="w"> </span><span class="kt">u32</span>: <span class="nb">PartialOrd</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Debug</span><span class="w"></span>
</code></pre></div>



<a name="196957973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957973">(May 08 2020 at 22:31)</a>:</h4>
<p>oh, that's not the imp't debug though, but that's true</p>



<a name="196957981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957981">(May 08 2020 at 22:31)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="k">where</span><span class="w"> </span><span class="kt">u32</span>: <span class="nc">for</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Debug</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">PartialOrd</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>



<a name="196957984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957984">(May 08 2020 at 22:31)</a>:</h4>
<p>that would be another plausible desugar</p>



<a name="196957987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957987">(May 08 2020 at 22:31)</a>:</h4>
<p>Oh, I see.</p>



<a name="196957988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957988">(May 08 2020 at 22:31)</a>:</h4>
<p>we don't yet support that notation, but we have to and will soon enough</p>



<a name="196957989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196957989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196957989">(May 08 2020 at 22:31)</a>:</h4>
<p>for GATs</p>



<a name="196958033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958033">(May 08 2020 at 22:32)</a>:</h4>
<p><em>that</em> interpretation does make sense</p>



<a name="196958037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958037">(May 08 2020 at 22:32)</a>:</h4>
<p>this is (imo) related to <code>'_</code> notation</p>



<a name="196958048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958048">(May 08 2020 at 22:32)</a>:</h4>
<p>So the question is, does this desugar to "you must accept any Debug" or "the call must be for a specific Debug"?</p>



<a name="196958049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958049">(May 08 2020 at 22:32)</a>:</h4>
<p>right now we don't I don't think accept</p>



<a name="196958060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958060">(May 08 2020 at 22:32)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Blah</span><span class="o">&lt;</span><span class="nb">&#39;_</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>



<a name="196958067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958067">(May 08 2020 at 22:32)</a>:</h4>
<p>but I think if we it should introduce a region in the same place as the <code>T</code> above, whatever we decided :)</p>



<a name="196958083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958083">(May 08 2020 at 22:32)</a>:</h4>
<p>I understand now.</p>



<a name="196958095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958095">(May 08 2020 at 22:32)</a>:</h4>
<p>I gotta go now, dinner time and end of day here</p>



<a name="196958135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958135">(May 08 2020 at 22:33)</a>:</h4>
<p>The specific case where I'd imagine using it would be for a specific impl, but this seems like an absolutely reasonable distinction. And if you already have a where clause, it's not that bad to have to extend it.</p>



<a name="196958141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958141">(May 08 2020 at 22:33)</a>:</h4>
<p>(I'm still reviewing the rustc impl code, that's the major to do I have left, plus to wrestle with my framing of things as scopes and see if I can make it make sense :)</p>



<a name="196958142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196958142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196958142">(May 08 2020 at 22:33)</a>:</h4>
<p>Thanks for all this work!</p>



<a name="196987909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196987909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196987909">(May 09 2020 at 11:48)</a>:</h4>
<p>I think <code>Named</code> should be <code>Type alias</code> and <code>Associated type value position</code> should be <code>Associated type (alias)</code>, which are the terms that have been previously used (at least informally).</p>



<a name="196987987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196987987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196987987">(May 09 2020 at 11:50)</a>:</h4>
<p><code>impl Trait for impl Type { }</code> — is this added just to have a name to refer to? This is not being considered?</p>



<a name="196988104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988104">(May 09 2020 at 11:53)</a>:</h4>
<p>I think several of these positions behave identically, but that seems to be intentional for now.</p>



<a name="196988391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988391">(May 09 2020 at 11:59)</a>:</h4>
<p>Re.</p>
<blockquote>
<p>Use the natural interpretation to guide the choice.</p>
</blockquote>
<p>I think if the choice is at all ambiguous, it should be disallowed. This feeds into the point about "It may be that the interpretation is not clear for readers", though it's slightly stronger.</p>



<a name="196988460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988460">(May 09 2020 at 12:01)</a>:</h4>
<blockquote>
<p>Existential types</p>
</blockquote>
<p>Also, let's not use this terminology: it's continually caused confusion in the past, because many people don't really understand what existential types are. We're using "opaque type" in the compiler, and that seems reasonable to use technically as well.</p>



<a name="196988538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988538">(May 09 2020 at 12:03)</a>:</h4>
<blockquote>
<p>Existential type aliases cannot be used in impl blocks</p>
</blockquote>
<p>This would be slightly more readable as: "It is not possible to <code>impl</code> methods for opaque types.".</p>



<a name="196988729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988729">(May 09 2020 at 12:09)</a>:</h4>
<p>I think the general guidelines match with my intuition, though I need to think more carefully about the nesting <code>impl Trait</code>: it seems quite plausible that we would never want to permit this.</p>



<a name="196988970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/196988970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#196988970">(May 09 2020 at 12:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988460" title="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988460">said</a>:</p>
<blockquote>
<blockquote>
<p>Existential types</p>
</blockquote>
<p>Also, let's not use this terminology: it's continually caused confusion in the past, because many people don't really understand what existential types are. We're using "opaque type" in the compiler, and that seems reasonable to use technically as well.</p>
</blockquote>
<p>To clarify, I don't think "universal/existential binders" cause confusion, but referring to <code>impl Trait</code> as an existential type does.</p>



<a name="197000962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/197000962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#197000962">(May 09 2020 at 16:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988970" title="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988970">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988460" title="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/196988460">said</a>:</p>
<blockquote>
<blockquote>
<p>Existential types</p>
</blockquote>
<p>Also, let's not use this terminology: it's continually caused confusion in the past, because many people don't really understand what existential types are. We're using "opaque type" in the compiler, and that seems reasonable to use technically as well.</p>
</blockquote>
<p>To clarify, I don't think "universal/existential binders" cause confusion, but referring to <code>impl Trait</code> as an existential type does.</p>
</blockquote>
<p>I think in the case of niko's notes it actually made a lot of sense, compared to previous attempts. The way return-position <code>impl Trait</code> is an existential within the forall of the next generic scope out perfectly captures the way that the actual type can depend on those generic parameters but not the function's value-level parameters.</p>



<a name="198212935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198212935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198212935">(May 20 2020 at 15:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> are you around by any chance?</p>



<a name="198221157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198221157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198221157">(May 20 2020 at 16:11)</a>:</h4>
<p>I am now...</p>



<a name="198224933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198224933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198224933">(May 20 2020 at 16:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> I was going to ask some questions about the impl Trait code but I think I figured out enough for the time being.</p>



<a name="198226210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198226210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198226210">(May 20 2020 at 16:51)</a>:</h4>
<p>Reminder <span class="user-group-mention" data-user-group-id="1977">@T-lang</span> that we have a design meeting in 10 mnutes -- I forgot to update the calendar, but the planned topic was <a href="https://hackmd.io/w_xcaFmASEqzVMC3J2L8Dw?edit">"impl Trait everywhere"</a>. <br>
I'm currently preparing a <a href="https://hackmd.io/w_xcaFmASEqzVMC3J2L8Dw?edit">hackmd</a> that I expect to use to drive the meeting.</p>



<a name="198227525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198227525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198227525">(May 20 2020 at 17:01)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1977">@T-lang</span> design meeting is now =)</p>



<a name="198228007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198228007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198228007">(May 20 2020 at 17:04)</a>:</h4>
<p>(computer and/or zoom is behaving weird; will try to rejoin in a sec)</p>



<a name="198234246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198234246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198234246">(May 20 2020 at 17:55)</a>:</h4>
<p>I just lost the meeting too</p>



<a name="198237256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198237256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198237256">(May 20 2020 at 18:18)</a>:</h4>
<p>So i'm not sure if we should keep editing the hackmd or not, so i'll just say here, but <code>Foo::foo::return</code> could be a general "phrase" for accessing the return type of any method or function. It's not an "expression" since it resolves to a type instead of a value.</p>



<a name="198291859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198291859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198291859">(May 21 2020 at 06:59)</a>:</h4>
<p>Would it be considered an inherent associated type?</p>



<a name="198293472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293472">(May 21 2020 at 07:28)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I also wonder if somefunc::arg&lt;2&gt; would work as a phrase to access the second argument.</p>



<a name="198293489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293489">(May 21 2020 at 07:28)</a>:</h4>
<p>Well, we'd need a keyword in place of arg...</p>



<a name="198293534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293534">(May 21 2020 at 07:29)</a>:</h4>
<p>Maybe somefunc::2, since normally you'd need an identifier?</p>



<a name="198293622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293622">(May 21 2020 at 07:30)</a>:</h4>
<p>yeah i hadn't thought that you'd need to name arg types too, but i guess it might come up</p>



<a name="198293688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293688">(May 21 2020 at 07:31)</a>:</h4>
<p>Or somefunc::fn&lt;2&gt; .</p>



<a name="198293808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198293808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198293808">(May 21 2020 at 07:33)</a>:</h4>
<p>there might be a limit to how much we can sanely reuse keywords XD</p>



<a name="198294397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198294397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198294397">(May 21 2020 at 07:43)</a>:</h4>
<p>okay okay, if we need inputs and outputs, and also not to flood the possibility space of what the user has to read too much, we could do <code>somefunc::type&lt;N&gt;</code> to get the type of the Nth argument, or <code>somefunc::type&lt;return&gt;</code> for the type of the return value.</p>



<a name="198294581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198294581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198294581">(May 21 2020 at 07:46)</a>:</h4>
<p><code>somefunc::in&lt;0&gt;</code></p>



<a name="198295339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198295339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198295339">(May 21 2020 at 07:58)</a>:</h4>
<p>ooooh</p>



<a name="198356237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356237">(May 21 2020 at 18:13)</a>:</h4>
<p>The <code>::return</code> syntax seems kind of wordy to me</p>



<a name="198356352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356352">(May 21 2020 at 18:14)</a>:</h4>
<p>e.g., imagine you have </p>
<div class="codehilite"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Service</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">launch</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Future</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>then you would write</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">launch_service</span><span class="o">&lt;</span><span class="n">S</span>: <span class="nc">Service</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">S</span>::<span class="n">launch</span>::<span class="k">return</span>: <span class="nb">Send</span>
</code></pre></div>



<a name="198356396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356396">(May 21 2020 at 18:14)</a>:</h4>
<p>vs </p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">launch_service</span><span class="o">&lt;</span><span class="n">S</span>: <span class="nc">Service</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">S</span>::<span class="n">Launch</span>: <span class="nb">Send</span>
</code></pre></div>



<a name="198356439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356439">(May 21 2020 at 18:15)</a>:</h4>
<p>or even <code>S::launch: Send</code></p>



<a name="198356519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356519">(May 21 2020 at 18:15)</a>:</h4>
<p>that said, another thing that would be useful is some way to say <em>all the async fns in this trait return Send futures</em> (or <em>all the <code>impl Future</code> ...</em>)</p>



<a name="198356603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198356603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198356603">(May 21 2020 at 18:16)</a>:</h4>
<p>something like (to use <code>return</code> notation)</p>
<div class="codehilite"><pre><span></span><code><span class="k">where</span><span class="w"> </span><span class="n">S</span>::<span class="o">*</span>::<span class="k">return</span>: <span class="nb">Send</span>
</code></pre></div>


<p>(not that I actually think I would want this syntax)</p>



<a name="198383447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198383447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198383447">(May 21 2020 at 22:08)</a>:</h4>
<p><a href="https://github.com/cramertj/impl-trait-goals/blob/impl-trait-in-traits/0000-impl-trait-in-traits.md">https://github.com/cramertj/impl-trait-goals/blob/impl-trait-in-traits/0000-impl-trait-in-traits.md</a> is the RFC that I had written for inferred associated types btw. It's quite old and outdated now, but it shows where my head was at one point in time.</p>



<a name="198392857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198392857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198392857">(May 21 2020 at 23:55)</a>:</h4>
<p>Rather than <code>::return</code>/<code>::fn</code>/<code>::arg</code>/etc, it might be nicer to come up with a syntax for the client to give that type a name it can use. (By analogy: pattern matching rather than projection, or C++20 requires-expressions rather than C++11 declval.) Maybe something like <code>where (for(s: &amp;S) { s.launch() }): F, F: Send</code>?</p>
<p>As const generics gets further along I expect people will need similar tools there anyway- things like <code>where doesnt_overflow({ X + 3 })</code> (or perhaps even <code>where { X + 3 &lt; Y }</code>). Some sort of cohesive tool for talking about expressions, even expressions pulled out of thin air like <code>for(s: &amp;S) { s.launch() }</code> might be a good way to handle <code>impl Trait</code> bounds as well.</p>



<a name="198472300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472300">(May 22 2020 at 17:45)</a>:</h4>
<p>I do want to say that</p>



<a name="198472309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472309">(May 22 2020 at 17:45)</a>:</h4>
<p>in general, I think that turbofish is kind of "meh"</p>



<a name="198472325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472325">(May 22 2020 at 17:45)</a>:</h4>
<p>especially when you have a long list of "optional" parameters</p>



<a name="198472353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472353">(May 22 2020 at 17:45)</a>:</h4>
<p>e.g., if we have <code>HashMap&lt;T, H(asher), A(llocator)&gt;</code></p>



<a name="198472373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472373">(May 22 2020 at 17:45)</a>:</h4>
<p>it'd be nice to  be able to specify the Allocator without speciying the hasher</p>



<a name="198472435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472435">(May 22 2020 at 17:46)</a>:</h4>
<p>I guess that being able to give some name might tie in with <code>impl Trait</code></p>



<a name="198472491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198472491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198472491">(May 22 2020 at 17:46)</a>:</h4>
<p>I'm not sure I quite understand <span class="user-mention" data-user-id="117495">@rpjohnst</span> your const generics examples though</p>



<a name="198484483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198484483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198484483">(May 22 2020 at 19:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/198472491">said</a>:</p>
<blockquote>
<p>I'm not sure I quite understand <span class="user-mention silent" data-user-id="117495">rpjohnst</span> your const generics examples though</p>
</blockquote>
<p>I could be totally wrong there, but my understanding is that, to use a const generic parameter in an expression, the parameter must be constrained enough that the use won't produce monomorphization-time errors- thus a need to put expressions in constraints.</p>



<a name="198540295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198540295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198540295">(May 23 2020 at 15:32)</a>:</h4>
<p>Argh, I intended to attend this meeting, but it slipped my mind with everything else that's going on <span aria-label="weary" class="emoji emoji-1f629" role="img" title="weary">:weary:</span></p>



<a name="198829244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198829244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198829244">(May 26 2020 at 22:26)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> -- I was wondering if you'd be interested in scheduling a time to chat to talk about impl Trait implementation issues. I just saw <a href="https://github.com/rust-lang/rust/pull/72080/">https://github.com/rust-lang/rust/pull/72080/</a> and I've been thinking about this as well.</p>



<a name="198918060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/198918060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#198918060">(May 27 2020 at 16:36)</a>:</h4>
<p>That sounds good. I'm generally free after 4:30  UTC</p>



<a name="199476657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199476657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199476657">(Jun 02 2020 at 11:16)</a>:</h4>
<p>Ping <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="199499852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199499852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199499852">(Jun 02 2020 at 14:29)</a>:</h4>
<p>Heh I was wondering where I started this thread, thanks <span class="user-mention" data-user-id="116118">@Matthew Jasper</span></p>



<a name="199500031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199500031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199500031">(Jun 02 2020 at 14:30)</a>:</h4>
<p>Also cc <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="199500108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199500108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199500108">(Jun 02 2020 at 14:30)</a>:</h4>
<p>I think best for me might be to try and talk more on Friday</p>



<a name="199500132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199500132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199500132">(Jun 02 2020 at 14:30)</a>:</h4>
<p>well or maybe Wed</p>



<a name="199504670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199504670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199504670">(Jun 02 2020 at 14:58)</a>:</h4>
<p>Either of those sounds fine for me</p>



<a name="199505137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199505137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199505137">(Jun 02 2020 at 15:01)</a>:</h4>
<p>I will try to review <a href="https://github.com/rust-lang/rust/issues/72080">#72080</a> in the meantime</p>



<a name="199657310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199657310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199657310">(Jun 03 2020 at 18:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> let's do friday, say 13:00 Boston time == 17:00 UTC I believe</p>



<a name="199905962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199905962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199905962">(Jun 05 2020 at 17:01)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> (and maybe <span class="user-mention" data-user-id="124288">@oli</span>)</p>



<a name="199906089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906089">(Jun 05 2020 at 17:02)</a>:</h4>
<p>So... I was hoping to talk a bit about impl trait implementation questions</p>



<a name="199906188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906188">(Jun 05 2020 at 17:03)</a>:</h4>
<p>I had hoped to do prep but mostly I just read <span class="user-mention" data-user-id="116118">@Matthew Jasper</span>'s PR -- in any case, I'm going to start typing and leaving notes and thoughts and doing a bit of investigating, and maybe if you folks are around now, that's great, else we can discuss more later</p>



<a name="199906212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906212">(Jun 05 2020 at 17:03)</a>:</h4>
<p><a href="https://hackmd.io/OgSPmb7URaemYMNL2hGbiA">hackmd</a></p>



<a name="199906539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906539">(Jun 05 2020 at 17:06)</a>:</h4>
<p>I'm here</p>



<a name="199906641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906641">(Jun 05 2020 at 17:07)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="199906678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906678">(Jun 05 2020 at 17:07)</a>:</h4>
<p>sorry, was afk for a sec, back now</p>



<a name="199906760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906760">(Jun 05 2020 at 17:08)</a>:</h4>
<p>OK, so, looking at the questions of implementation...</p>



<a name="199906771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906771">(Jun 05 2020 at 17:08)</a>:</h4>
<p>I guess that there are a few categories of things going on</p>



<a name="199906794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906794">(Jun 05 2020 at 17:08)</a>:</h4>
<p>for me a big goal is enabling people to return futures/closures/etc in trait impls</p>



<a name="199906888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906888">(Jun 05 2020 at 17:09)</a>:</h4>
<p>which I guess is basically a pattern of </p>
<div class="codehilite"><pre><span></span><code><span class="k">type</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">P0</span><span class="o">..</span><span class="p">.</span><span class="n">Pn</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Something</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">P0</span><span class="o">..</span><span class="n">Pn</span><span class="o">&gt;</span><span class="w"> </span><span class="n">SomeTrait</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Type</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">P0</span><span class="o">..</span><span class="n">Pn</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">method</span><span class="p">(</span><span class="o">..</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199906964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906964">(Jun 05 2020 at 17:10)</a>:</h4>
<p>I bring this up because there is a distinct case where the opaque type appears in the arguments of the fn</p>



<a name="199906981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199906981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199906981">(Jun 05 2020 at 17:10)</a>:</h4>
<p>and I think that this case is more challenging and also harder for our implementation</p>



<a name="199907001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907001">(Jun 05 2020 at 17:10)</a>:</h4>
<p>so in particular i'm looking at "are there important use cases we could prioritize for stabilization"</p>



<a name="199907028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907028">(Jun 05 2020 at 17:11)</a>:</h4>
<p>I think that opaque types where the "defining uses" are in the return type only are such a case</p>



<a name="199907178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907178">(Jun 05 2020 at 17:12)</a>:</h4>
<p>Yes</p>



<a name="199907287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907287">(Jun 05 2020 at 17:13)</a>:</h4>
<p>I'm trying now to find my older hackmd</p>



<a name="199907305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907305">(Jun 05 2020 at 17:13)</a>:</h4>
<p>where I had a more comprehensive list of where impl Trait could appear</p>



<a name="199907315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907315">(Jun 05 2020 at 17:13)</a>:</h4>
<p>I guess it was at the top of this topic</p>



<a name="199907353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907353">(Jun 05 2020 at 17:13)</a>:</h4>
<p><a href="https://github.com/nikomatsakis/lang-team/blob/impl-trait-everywhere/src/design_notes/impl_trait_everywhere.md">here they are</a></p>



<a name="199907461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907461">(Jun 05 2020 at 17:14)</a>:</h4>
<p>oh, right, it was not a gist..</p>



<a name="199907512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907512">(Jun 05 2020 at 17:15)</a>:</h4>
<p>so in particular the reason to separate out the return position</p>



<a name="199907533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907533">(Jun 05 2020 at 17:15)</a>:</h4>
<p>There's also <a href="https://hackmd.io/w_xcaFmASEqzVMC3J2L8Dw?edit">https://hackmd.io/w_xcaFmASEqzVMC3J2L8Dw?edit</a></p>



<a name="199907534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907534">(Jun 05 2020 at 17:15)</a>:</h4>
<p>is that it doesn't encounter the challenge of "how to think about the opaque type during inference"</p>



<a name="199907601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907601">(Jun 05 2020 at 17:16)</a>:</h4>
<p>oh yes</p>



<a name="199907604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907604">(Jun 05 2020 at 17:16)</a>:</h4>
<p>ok</p>



<a name="199907644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907644">(Jun 05 2020 at 17:16)</a>:</h4>
<p>so many notes :)</p>



<a name="199907669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907669">(Jun 05 2020 at 17:16)</a>:</h4>
<p>I guess I'm curious to see if there are any problems with other positions</p>



<a name="199907700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907700">(Jun 05 2020 at 17:16)</a>:</h4>
<p>I think usage in const/static doesn't present any <em>particular</em> difficulties, even if it currently errors more than we'd like?</p>



<a name="199907755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907755">(Jun 05 2020 at 17:17)</a>:</h4>
<p>I'm not 100% sure what the status is of <code>let x: impl Trait = ..</code> after your PR, I remember the impl before had some serious flaws</p>



<a name="199907895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907895">(Jun 05 2020 at 17:18)</a>:</h4>
<p>it seems to me that these are the "big categories" though:</p>
<ul>
<li>all "defining uses" are outputs (<code>-&gt; impl Trait</code>, <code>const X: impl Trait</code>)</li>
<li>"defining use" in fn body (<code>let x: impl Trait</code> or <code>let x: Foo</code>)</li>
<li>"defining use" in inputs (<code>fn foo(x: OpaqueType)</code>)</li>
</ul>



<a name="199907899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907899">(Jun 05 2020 at 17:18)</a>:</h4>
<p>I think it's still pretty bad. I think that all I did was change one ICE for another that gives a slightly better message.</p>



<a name="199907924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907924">(Jun 05 2020 at 17:18)</a>:</h4>
<p>I probably ordered those wrong</p>



<a name="199907943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907943">(Jun 05 2020 at 17:18)</a>:</h4>
<p>in that if you do this order:</p>



<a name="199907963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907963">(Jun 05 2020 at 17:18)</a>:</h4>
<ul>
<li>all "defining uses" are outputs (<code>-&gt; impl Trait</code>, <code>const X: impl Trait</code>)</li>
<li>"defining use" in inputs (<code>fn foo(x: OpaqueType)</code>)</li>
<li>"defining use" in fn body (<code>let x: impl Trait</code> or <code>let x: Foo</code>)</li>
</ul>



<a name="199907973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907973">(Jun 05 2020 at 17:18)</a>:</h4>
<p>it might be more the order of priority?</p>



<a name="199907980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199907980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199907980">(Jun 05 2020 at 17:19)</a>:</h4>
<p>I'm actually not sure about that</p>



<a name="199908013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908013">(Jun 05 2020 at 17:19)</a>:</h4>
<p>I mean you never <em>need</em> <code>let x: impl Foo</code> in a fn body, but it might be in some senses simpler, and I've found I really would like it when writing docs</p>



<a name="199908035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908035">(Jun 05 2020 at 17:19)</a>:</h4>
<p>but anyhow</p>



<a name="199908047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908047">(Jun 05 2020 at 17:19)</a>:</h4>
<p>There's also the non-defining use in defining scope issue.</p>



<a name="199908061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908061">(Jun 05 2020 at 17:19)</a>:</h4>
<p>do you mean the "passthrough" use case?</p>



<a name="199908069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908069">(Jun 05 2020 at 17:19)</a>:</h4>
<p>yes</p>



<a name="199908123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908123">(Jun 05 2020 at 17:20)</a>:</h4>
<p>specifically I mean that</p>



<a name="199908143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908143">(Jun 05 2020 at 17:20)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="nc">OpaqueType</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">OpaqueType</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>is supposed to work</p>



<a name="199908152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908152">(Jun 05 2020 at 17:20)</a>:</h4>
<p>so, that is an issue, but I note that it requires a "defining use" in inputs</p>



<a name="199908171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908171">(Jun 05 2020 at 17:20)</a>:</h4>
<p>maybe I'm using "defining use" in a confusing way</p>



<a name="199908181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908181">(Jun 05 2020 at 17:20)</a>:</h4>
<p>I don't actually mean what the compiler means by it</p>



<a name="199908201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908201">(Jun 05 2020 at 17:20)</a>:</h4>
<p>I mean what the RFC means by, that is, basically <em>any</em> use that is inside the "scope" of the opaque type</p>



<a name="199908249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908249">(Jun 05 2020 at 17:21)</a>:</h4>
<p>let's call it .. in-scope use?</p>



<a name="199908379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908379">(Jun 05 2020 at 17:22)</a>:</h4>
<blockquote>
<p>Ultimately all <code>impl Trait</code> outside of fn arguments desugar to a "opaque type" that has some "defining scope".</p>
<p>This scope may be a particular item or it may be the enclosing module.</p>
<p>A "in-scope use" is a reference to that opaque type from within the "defining scope".</p>
</blockquote>



<a name="199908402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908402">(Jun 05 2020 at 17:22)</a>:</h4>
<p>That's my mental model, sound correct?</p>



<a name="199908419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908419">(Jun 05 2020 at 17:22)</a>:</h4>
<p>Sounds good</p>



<a name="199908571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908571">(Jun 05 2020 at 17:24)</a>:</h4>
<blockquote>
<p><strong>Layer 1. All "in-scope uses" are in a "defining" location.</strong></p>
<p>A "defining" location is one of the following:</p>
<ul>
<li>fn return type</li>
<li>const/static type annotation</li>
</ul>
</blockquote>



<a name="199908580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908580">(Jun 05 2020 at 17:24)</a>:</h4>
<blockquote>
<p>What these have in common is that there are no expressions that the user can reference that yield values of the opaque type until the opaque type is fully inferred (it would result in a cycle error).</p>
<p>Claim: the current implementation in these cases matches the RFC.</p>
</blockquote>



<a name="199908585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908585">(Jun 05 2020 at 17:24)</a>:</h4>
<p>Sound correct?</p>



<a name="199908601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908601">(Jun 05 2020 at 17:24)</a>:</h4>
<p>We should probably test that claim :)</p>



<a name="199908761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908761">(Jun 05 2020 at 17:26)</a>:</h4>
<p>I wonder how to think about </p>
<div class="codehilite"><pre><span></span><code><span class="k">type</span> <span class="nc">OpaqueType</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Trait</span><span class="p">;</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">x</span>: <span class="nc">OpaqueType</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199908780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199908780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199908780">(Jun 05 2020 at 17:26)</a>:</h4>
<p>It is not a member of that layer, clearly :)</p>



<a name="199909482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909482">(Jun 05 2020 at 17:32)</a>:</h4>
<blockquote>
<p>What these have in common is that there are no expressions that the user can reference that yield values of the opaque type until the opaque type is fully inferred (it would result in a cycle error).</p>
</blockquote>
<p>I'm not sure what you mean by this. It's possible to write:</p>
<div class="codehilite"><pre><span></span><code><span class="k">type</span> <span class="nc">A</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="nb">Sized</span><span class="p">;</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="n">rec</span>: <span class="kt">bool</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="k">if</span><span class="w"> </span><span class="n">rec</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">          </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span><span class="w"></span>
<span class="w">     </span><span class="p">}</span><span class="w"></span>
<span class="w">     </span><span class="nb">String</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199909779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909779">(Jun 05 2020 at 17:35)</a>:</h4>
<p>Hmm ok I guess that's just false :)</p>



<a name="199909802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909802">(Jun 05 2020 at 17:35)</a>:</h4>
<p>I guess it's only if we have to evaluate an auto trait</p>



<a name="199909806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909806">(Jun 05 2020 at 17:35)</a>:</h4>
<p>that you get the cycle error</p>



<a name="199909868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909868">(Jun 05 2020 at 17:36)</a>:</h4>
<p>that gets at something I was just thinking about</p>



<a name="199909888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909888">(Jun 05 2020 at 17:36)</a>:</h4>
<p>I'm not sure I entirely know what the expected behavior is in this case</p>



<a name="199909900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909900">(Jun 05 2020 at 17:36)</a>:</h4>
<p>is the type of <code>x</code> "opaque"</p>



<a name="199909905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909905">(Jun 05 2020 at 17:36)</a>:</h4>
<p>or "revealed"</p>



<a name="199909980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199909980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199909980">(Jun 05 2020 at 17:37)</a>:</h4>
<p>similarly if you had </p>
<div class="codehilite"><pre><span></span><code><span class="k">type</span> <span class="nc">OpaqueType</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Debug</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span>: <span class="nc">OpaqueType</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">22_</span><span class="k">u32</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="n">y</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">44</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>does that compile?</p>



<a name="199910061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910061">(Jun 05 2020 at 17:38)</a>:</h4>
<p>I ask because I could imagine an alternate impl strategy where we don't "replace" opaque-types-being-inferred with fresh inference variables</p>



<a name="199910077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910077">(Jun 05 2020 at 17:38)</a>:</h4>
<p>but rather collect the constraints</p>



<a name="199910105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910105">(Jun 05 2020 at 17:38)</a>:</h4>
<p>it might be ever so slightly backwards incompatible</p>



<a name="199910111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910111">(Jun 05 2020 at 17:38)</a>:</h4>
<p>for a case like</p>



<a name="199910121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910121">(Jun 05 2020 at 17:38)</a>:</h4>
<p>The current behaviour is opaque I think.</p>



<a name="199910156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910156">(Jun 05 2020 at 17:39)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Trait</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">something</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">XXX</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">YYY</span><span class="p">;</span><span class="w"> </span><span class="c1">// maybe the type of XXX informs  the expected type for YYY here?</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="199910188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910188">(Jun 05 2020 at 17:39)</a>:</h4>
<p>but I imagine that would be .. very rare .. and perhaps solveable, at worst via a hack</p>



<a name="199910370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910370">(Jun 05 2020 at 17:41)</a>:</h4>
<p>I could imagine either behavior, I'm not sure what I expect</p>



<a name="199910379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910379">(Jun 05 2020 at 17:41)</a>:</h4>
<p><em>but</em> I see some advantages to this impl strategy</p>



<a name="199910388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910388">(Jun 05 2020 at 17:41)</a>:</h4>
<p>it would I think help with the problems of impl Trait in argment position etc</p>



<a name="199910537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910537">(Jun 05 2020 at 17:42)</a>:</h4>
<p>not sure if what I sketched is clear</p>



<a name="199910543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910543">(Jun 05 2020 at 17:42)</a>:</h4>
<p>what I imagine is maybe something like this</p>



<a name="199910556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910556">(Jun 05 2020 at 17:42)</a>:</h4>
<p>we have in the inference context a list of "opaque types being inferred"</p>



<a name="199910594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910594">(Jun 05 2020 at 17:43)</a>:</h4>
<p>whenever we are asked to equate an opaque type .. xxx .. ok, what I was about to write would not work :)</p>



<a name="199910629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910629">(Jun 05 2020 at 17:43)</a>:</h4>
<p>well, I'll write it anyway, the idea would be that unification succeeds, but we collect the type you unified with</p>



<a name="199910683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910683">(Jun 05 2020 at 17:44)</a>:</h4>
<p>one reason it would not work is that you have things like "test if this impl for String applies"</p>



<a name="199910698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910698">(Jun 05 2020 at 17:44)</a>:</h4>
<p>(and you basically never want those impls to apply)</p>



<a name="199910742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910742">(Jun 05 2020 at 17:44)</a>:</h4>
<p>so we'd have to sort of distinguish a bit better what we mean there</p>



<a name="199910833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199910833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199910833">(Jun 05 2020 at 17:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/impl.20Trait.20everywhere/near/199910698">said</a>:</p>
<blockquote>
<p>(and you basically never want those impls to apply)</p>
</blockquote>
<p>except maybe when we do? sometimes impl selection affects inference, after all</p>



<a name="199911020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911020">(Jun 05 2020 at 17:47)</a>:</h4>
<p>in terms of what behavior we want, <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> mentioned a "guideline" that maybe helps. As much as possible, you should be able to take a <code>impl Trait</code> and "extract" it to a type alias and things should kind of work the same. This is only sort of possible because of "universal-to-existential" conversion, though. But it would suggest that</p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="nc">impl</span><span class="w"> </span><span class="n">Debug</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">22</span><span class="p">;</span><span class="w"></span>
<span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">44</span><span class="w"></span>
</code></pre></div>


<p>is an error, so it should be the same if you do</p>
<div class="codehilite"><pre><span></span><code><span class="k">type</span> <span class="nc">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Debug</span><span class="p">;</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="nc">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">22</span><span class="p">;</span><span class="w"></span>
<span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">44</span><span class="w"></span>
</code></pre></div>



<a name="199911388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911388">(Jun 05 2020 at 17:50)</a>:</h4>
<p>I'm thinking about that recursive case and trying to decide whether it implies that I am wrong that we could potentially move faster towards stabilizing impl trait in return position</p>



<a name="199911410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911410">(Jun 05 2020 at 17:51)</a>:</h4>
<p>presumably the compiler treats such types as opaque</p>



<a name="199911437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911437">(Jun 05 2020 at 17:51)</a>:</h4>
<p>yes, it does</p>



<a name="199911445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911445">(Jun 05 2020 at 17:51)</a>:</h4>
<p>so e.g. this does not compile</p>



<a name="199911461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911461">(Jun 05 2020 at 17:51)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">std</span>::<span class="n">fmt</span>::<span class="n">Debug</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kc">false</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=cf0280260f6828c6059476ed81e03ef9">playground</a></p>



<a name="199911827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911827">(Jun 05 2020 at 17:54)</a>:</h4>
<p>so I guess one thing to do might be to experiment with this idea I was describing, though I'd have to decide how to handle the distinct between "probing" whether a type can unify and "declaring" that it must unify</p>



<a name="199911902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911902">(Jun 05 2020 at 17:55)</a>:</h4>
<p>I was already thinking that the real way to handle this would be to have the "obligations" that get propagated back encode information about the constraints on opaque types that are required (similar to region constraints), which might be part of the answer</p>



<a name="199911930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911930">(Jun 05 2020 at 17:55)</a>:</h4>
<p>...this is also similar to the "semantic vs syntactic equality" split, maybe?, that we are pursuing in chalk...</p>



<a name="199911955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199911955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199911955">(Jun 05 2020 at 17:55)</a>:</h4>
<p>if we <em>could</em> get it to work, it seems like it would behave much better and also fit the RFC more closely</p>



<a name="199912330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/199912330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#199912330">(Jun 05 2020 at 17:58)</a>:</h4>
<p>got to go, will ponder a bit, I'm leaning towards "it's worth experimenting some to see what problems arise"</p>



<a name="200881619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/200881619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#200881619">(Jun 15 2020 at 12:24)</a>:</h4>
<blockquote>
<p>in terms of what behavior we want, @Taylor Cramer mentioned a "guideline" that maybe helps. As much as possible, you should be able to take a impl Trait and "extract" it to a type alias and things should kind of work the same. This is only sort of possible because of "universal-to-existential" conversion, though.</p>
</blockquote>
<p>I think this could possibly be taken to be a <em>definition</em> of impl Trait, which may make thinking of it more intuitive. What are the cases where this guideline fails?</p>



<a name="200902513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/200902513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#200902513">(Jun 15 2020 at 15:13)</a>:</h4>
<p>well </p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="nc">impl</span><span class="w"> </span><span class="n">Trait</span><span class="p">)</span><span class="w"></span>
</code></pre></div>


<p>is the obvious example, to start</p>



<a name="200905010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/200905010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#200905010">(Jun 15 2020 at 15:28)</a>:</h4>
<p>Ah, I meant non-argument-position impl Trait, which is really a distinct feature.</p>



<a name="200928502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/impl%20Trait%20everywhere/near/200928502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/impl.20Trait.20everywhere.html#200928502">(Jun 15 2020 at 18:36)</a>:</h4>
<p>I think the property already holds for cases of "non-argument-position" impl Trait, modulo that you may need to create a module to contain things.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>